Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(types): less strict callbacks return type #289

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

LavransBjerkestrand
Copy link
Contributor

Proposed changes

allows hook callbacks to call functions that have a return value other than void without wrapping in a closure. E.g. onSuccess: () => toast.success('...') where toast.success returns the toast id. I understand that the return value of the callback isn't used for anything but this allows for slightly cleaner code imo.

Related issue(s) or discussion(s)


allows hook callbacks to call functions that have a return value other than void without wrapping in
a closure. E.g. onSuccess: () => toast.success('...') where toast.success returns the toast id.
Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-safe-action-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 2:51pm

Copy link

vercel bot commented Oct 28, 2024

@LavransBjerkestrand is attempting to deploy a commit to the Edoardo Ranghieri's projects Team on Vercel.

A member of the Team first needs to authorize it.

@TheEdoRan
Copy link
Owner

TheEdoRan commented Oct 28, 2024

I understand that the return value of the callback isn't used for anything but this allows for slightly cleaner code imo.

Yep, callbacks are typed void mainly to inform the user that the return value is absolutely not used in any way or form, but I can understand the cleaner code argument, since a one-liner can become a two-liner. However, I also don't think that allowing less strict typings will cause bugs in apps, because callbacks behavior is pretty self-explanatory (and documented), so it's ok to merge this, in my opinion. Thank you for your contribution!

@TheEdoRan TheEdoRan changed the title refactor: less strict hook callback return type refactor(types): less strict callbacks return type Oct 28, 2024
@TheEdoRan TheEdoRan merged commit dc120df into TheEdoRan:main Oct 28, 2024
3 of 4 checks passed
Copy link

🎉 This PR is included in version 7.9.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants